home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / pcl10.arc / PCL.DOC < prev    next >
Text File  |  1991-07-20  |  45KB  |  2,315 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                       Pascal Communications Library ( PCL )
  7.  
  8.                          for Turbo Pascal 4.0 through 6.0
  9.  
  10.  
  11.  
  12.  
  13.  
  14.                           USER REFERENCE MANUAL
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.                                Version 1.0
  22.  
  23.                                20 May 1991
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.                             Copyright (C) 1991
  31.                               By MarshallSoft
  32.                             All rights reserved
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.                                 MarshallSoft
  40.                                 PO Box 4543
  41.                              Hunstville, AL 35815
  42.                                (205) 881-4630
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. Page 1
  66.  
  67.  
  68.  
  69.  
  70.                              Table of Contents
  71.  
  72.  
  73.  
  74.  
  75.  
  76.        Chapter                                     Page
  77.  
  78.        Introduction.................................3
  79.        Registration.................................4
  80.        Serial COM Ports.............................5
  81.        RS232........................................6
  82.        National INS8250 UART........................7
  83.        Revision History.............................7
  84.        Warranty.....................................7
  85.        Using the Library............................8
  86.           Compiling.................................9
  87.           Problems.................................10
  88.        Library Reference...........................11
  89.           SioBaud..................................12
  90.           SioBrkKey................................13
  91.           SioBrkSig................................14
  92.           SioCrtWrite..............................15
  93.           SioDTR...................................16
  94.           SioDelay.................................17
  95.           SioDone..................................18
  96.           SioError.................................19
  97.           SioGetc..................................20
  98.           SioKeyPress..............................21
  99.           SioKeyRead...............................22
  100.           SioLine..................................23
  101.           SioModem.................................24
  102.           SioParms.................................25
  103.           SioPutc..................................26
  104.           SioRTS...................................27
  105.           SioReset.................................28
  106.           SioRxBuf.................................29
  107.           SioRxFlush...............................30
  108.           SioRxQue.................................31
  109.           SioTimer.................................32
  110.           SioUnGetc................................33
  111.        Function Summary............................34
  112.        Error Code Summary..........................35
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131. Page 2
  132.  
  133.  
  134.  
  135.  
  136.                              Introduction
  137.  
  138.  
  139.  
  140.        The    Pascal  Communications  Library  ( PCL ) is an asynchronous
  141.        communications   library   designed   for   experienced   software
  142.        developers  programming in Turbo Pascal ( version 4.0 and up).  An
  143.        IBM PC/XT/AT or compatible is required.  The PCL features:
  144.  
  145.           o  16 communications functions + 6 support functions.
  146.           o  Receiver is interrupt driven.
  147.           o  Runs from 300 baud to 115,200 baud.
  148.           o  Supports COM1, COM2, COM3, and COM4.
  149.           o  Adjustable receive queues from 8 bytes to 16 KB.
  150.           o  Control-BREAK error exit.
  151.           o  11 comm error conditions trapped.
  152.           o  Allows 2 ports to run concurrently.
  153.           o  Complete modem control & status.
  154.           o  Written in hand optimized assembly language.
  155.           o  Low overhead & very reliable !
  156.  
  157.        A typical application  program  using  PCL  might  look  like  the
  158.        following code outline:
  159.  
  160.        +----------------------------------------------------------------+
  161.        | program YourProgram                                            |
  162.        | uses PCL;                                                      |
  163.        | ...                                                            |
  164.        | ...                                                            |
  165.        | var Buffer : array[0..1023] of Char;                           |
  166.        | ...                                                            |
  167.        | begin (* YourProgram *)                                        |
  168.        |    RetCode := SioRxBuf(Port,Buffer,Size1024);                  |
  169.        |    RetCode := SioParms(Port,NoParity,OneStopBit,WordLength8);  |
  170.        |    RetCode := SioReset(Port,Baud2400);                         |
  171.        |    ...                                                         |
  172.        |    ... ( application code )                                    |
  173.        |    ...                                                         |
  174.        |    RetCode := SioDone(Port);                                   |
  175.        | end. (* YourProgram *)                                         |
  176.        +----------------------------------------------------------------+
  177.  
  178.        A simple terminal emulator program CALLPGM.C is provided in source
  179.        code  form  as an example of the use of PCL functions. CALLPGM can
  180.        be used to call up bulletin board services or mainframe computers.
  181.  
  182.        If you find any problems with the  Pascal  Communications  Library
  183.        or  have any suggestions for improvement, please call or write.  A
  184.        C language version of PCL ( called CCL )  is available.
  185.  
  186.        Custom versions of PCL can be developed for special needs.  Custom
  187.        communication packages can also be developed. Call for prices.
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197. Page 3
  198.  
  199.  
  200.  
  201.  
  202.                              Registration
  203.  
  204.  
  205.  
  206.        The  shareware  version  of  PCL.LIB  is  provided so that you may
  207.        personally determine the usefulness of the product  for  yourself.
  208.        If you can use PCL, please register your use with us.
  209.  
  210.                 MarshallSoft
  211.                 PO Box 4543
  212.                 Huntsville, AL
  213.                 35815-4543
  214.  
  215.        Please  pay  by  check  in  US  dollars.   Payment  must accompany
  216.        purchase orders. Print the file PCL.INV if an invoice  is  needed.
  217.        The registered package is $35 postpaid and includes:
  218.  
  219.           o  PCL.PAS      PCL Unit.
  220.           o  PCL_LIB.ASM  PCL library source code.
  221.                           ( without the shareware screen )
  222.           o  PCL.DOC      PCL User Reference Manual.
  223.           o  Backbone bound printed User Reference Manual.
  224.           o  Telephone support for one year.
  225.           o  All future updates are $10
  226.  
  227.        PCL_LIB.ASM is the source code for the library. The source code is
  228.        copyrighted  by MarshallSoft. The user is granted a license to use
  229.        the PCL object code in his own application only.   PCL_LIB.ASM  is
  230.        not shareware and may not be sold or given away to anyone.
  231.  
  232.        The  registered  user  will  receive  the latest version of PCL by
  233.        return mail.  A 5.25" diskette is provided unless a 3.5"  diskette
  234.        is requested when ordering.
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263. Page 4
  264.  
  265.  
  266.  
  267.  
  268.                              Serial COM Ports
  269.  
  270.  
  271.  
  272.        IBM PC compatible computers can have up to four serial ports.  The
  273.        BIOS   table   located  at  address  40:0000  has  room  for  four
  274.        communication port addresses: COM1 to COM4. During  boot  up,  the
  275.        COM1  and  COM2  addresses  are placed in the BIOS table providing
  276.        that the hardware is present. Unfortunately,  the  COM3  and  COM4
  277.        addresses  are not placed in the table in DOS through version 3.3.
  278.        This can be corrected by using DEBUG  to  assemble  the  following
  279.        program  SETCOM3  which  should be added to the AUTOEXEC.BAT file.
  280.        When executed, this program will  place  the  standard  COM3  port
  281.        address  03E8 in the BIOS table. For COM4, change 03E8 to 02E8 and
  282.        [0004] to [0006].
  283.  
  284.  
  285.  
  286.                    PUSH DS
  287.                    MOV AX,0040
  288.                    MOV DS,AX
  289.                    MOV AX,03E8
  290.                    MOV [0004],AX
  291.                    POP DS
  292.                    MOV AX,4C00
  293.                    INT 21
  294.  
  295.  
  296.        Please note that you must have the physical hardware present !
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329. Page 5
  330.  
  331.  
  332.  
  333.  
  334.                              RS-232C
  335.  
  336.  
  337.  
  338.        RS-232 is the name of the serial data interface standard  used  to
  339.        connect  computers  to  modems.  Most IBM compatible computers are
  340.        built with at least one serial port and use either DB9 ( 9  pin  )
  341.        or DB25 ( 25 pin ) connectors.
  342.  
  343.        A  summary  of  these  pins  and their function follows.  For more
  344.        detailed information, refer to one of the many books dealing  with
  345.        RS-232 interfacing.
  346.  
  347.        Signal Ground Pin 7 (DB25), Pin 5 (DB9)
  348.  
  349.        The SG line is used as the common signal ground, and  must  always
  350.        be connected.
  351.  
  352.        Transmit Data Pin 2 (DB25), Pin 3 (DB9)
  353.  
  354.        The TX line is used to carry data from the computer to the modem.
  355.  
  356.        Receive Data Pin 3 (DB25), Pin 2 (DB9)
  357.  
  358.        The RX line is used to carry data from the modem to the computer.
  359.  
  360.        Data Terminal Ready Pin 20 (DB25), Pin 4 (DB9)
  361.  
  362.        The  DTR  line is used by the computer to signal the modem that it
  363.        is ready.
  364.  
  365.        Data Set Ready Pin 6 (DB25), Pin 6 (DB9)
  366.  
  367.        The DSR line is used by the modem to signal the computer  that  it
  368.        is ready.
  369.  
  370.        Request to Send Pin 4 (DB25), Pin 7 (DB9)
  371.  
  372.        The  RTS  line  is  used  to "turn the line around" in half duplex
  373.        modems, but is not necessary in full duplex modems.
  374.  
  375.        Clear to Send Pin 5 (DB25), Pin 8 (DB9)
  376.  
  377.        The  CTS  line, like the RTS line, in not necessary in full duplex
  378.        modems.
  379.  
  380.        Data Carrier Detect Pin 8 (DB25), Pin 1 (DB9)
  381.  
  382.        The DCD line is used by the modem to signal the  computer  that  a
  383.        data carrier signal is present.
  384.  
  385.        Ring Indicator Pin 22 (DB25), Pin 9 (DB9)
  386.  
  387.        The RI line is asserted when a 'ring' occurs.
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395. Page 6
  396.  
  397.  
  398.  
  399.  
  400.                              National INS8250
  401.  
  402.  
  403.  
  404.        The   Pascal  Communications  Library  is  based  on  the standard
  405.        National INS8250 UART. The  8250  consists  of  6  register  ports
  406.        based at the following standard addresses:
  407.  
  408.           COM1 = 3F8H  COM2 = 2F8H  COM3 = 3E8H  COM4 = 2E8H
  409.  
  410.        If  you  are not familiar with the INS8250, several good books are
  411.        available.  Although a knowledge of the 8250 is not  necessary  to
  412.        use  PCL,  a  general  knowledge  of  the  theory  of operation of
  413.        Univeral  Asynchronous  Receiver  /  Transmitters  (  UARTs  )  is
  414.        recommended.
  415.  
  416.        Offset R/W Register
  417.  
  418.          0       R/W   Receiver ( read ) / Transmitter ( write )
  419.          1       R/W   Interrupt Enable
  420.          2       R     Interrupt Identification
  421.          3       R/W   Data Format ( Line Control )
  422.          4       R/W   RS-232 ( Modem ) Control
  423.          5       R/W   Line Status
  424.          6       R/W   RS-232 ( Modem ) Status
  425.  
  426.  
  427.  
  428.                              Revision History
  429.  
  430.  
  431.  
  432.        Version 1.0 -- 20 May 1991 -- original release.
  433.  
  434.  
  435.  
  436.  
  437.                              Warranty
  438.  
  439.  
  440.  
  441.        The user of this software assumes all liability for its use. In no
  442.        case shall MarshallSoft be liable for any damages,  including  any
  443.        incidental or consequential damages.
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461. Page 7
  462.  
  463.  
  464.  
  465.  
  466.                              Using the Library
  467.  
  468.  
  469.  
  470.        The  first  thing  to  do  is  to  copy all the files from the PCL
  471.        distribution disk to a working disk,  and  put  the  original  PCL
  472.        distribution disk in a safe place.
  473.  
  474.        The PCL has been tested on a TANDY 1000 ( IBM PC clone ), a  TANDY
  475.        3000  (  IBM  AT  clone  ), a TANDY 1400LT ( IBM XT clone ), and a
  476.        Gateway 2000 Cache ( 25 MHZ 80386-DX ).
  477.  
  478.        For  an  example of PCL use, examine the terminal emulator program
  479.        CALLPGM.PAS. The user should compile CALLPGM.PAS as a test of  the
  480.        library.
  481.  
  482.        If you have two computers, then you can connect them together with
  483.        a  null modem cable and run CALLPGM on both machines.  Whatever is
  484.        typed on one machine should appear on the other, and  vice  versa.
  485.        Depending  on  the  design  of the null modem cable, CALLPGM.PAS may
  486.        need to be modified so that it does not  wait  for  DSR.  This  is
  487.        clearly documented in the CALLPGM.PAS code.
  488.  
  489.        If you have a modem, then use CALLPGM  to  call  up  any  bulletin
  490.        board  system  (  BBS  ).   There  are  many  free BBSs around the
  491.        country. Look in any issue of "Computer Shopper"  (  available  in
  492.        bookstores,  computer  shops, and many grocery stores ) for a list
  493.        of current systems.
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527. Page 8
  528.  
  529.  
  530.  
  531.  
  532.                              Compiling
  533.  
  534.  
  535.        Registered  users  may  wish to assemble PCL_LIB.ASM.  Use the /MX
  536.        switch in order to disable automatic conversion from lower case to
  537.        to upper case. To assemble using the Microsoft assembler:
  538.  
  539.              MASM PCL_LIB /MX;
  540.  
  541.        To build the library TPU:
  542.  
  543.              TPC PCL
  544.  
  545.        To compile the sample program:
  546.  
  547.              TPC CALLPGM
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593. Page 9
  594.  
  595.  
  596.  
  597.  
  598.                              Problems
  599.  
  600.  
  601.        If  you cannot get your application to run properly, first compile
  602.        and run the terminal emulator program  CALLPGM  provided  on  your
  603.        distribution disk.
  604.  
  605.        If  CALLPGM  runs  correctly,  then  you  have  made a programming
  606.        mistake in  your  application.   MarshallSoft  cannot  debug  your
  607.        application,  especially  over  the  telephone!  However, consider
  608.        each of  the  following  when  searching  for  an  error  in  your
  609.        application.
  610.  
  611.        1.  Did you include the "uses PCL" statement ?
  612.  
  613.        2.  Is your receive buffer large enough ? If you are using 1K data
  614.        blocks in a file transfer  protocol  such  as  YMODEM,  then  your
  615.        receive buffer should be 1K or more.
  616.  
  617.        3.   Have  you  selected too high a baud rate ?  Always start with
  618.        the slowest baud rate.  If only one COM port  is  being  run,  you
  619.        should be able to run at 38400 baud.
  620.  
  621.        4.    Are  you  attempting  to  run  another  application  in  the
  622.        background ?  Try running without any other  programs  running  in
  623.        the background.
  624.  
  625.        5.  If you are running two COM ports simultaneously, are you using
  626.        seperate receive buffers ? ( you should ).
  627.  
  628.        6.  Did SioReset return a zero value ?  If not, then you must call
  629.        SioReset again. See CALLPGM.PAS for an example.
  630.  
  631.        If  CALLPGM  does  not  run,  then  either  there  is  a  physical
  632.        connection problem or your computer isn't  as  compatible  as  you
  633.        thought!   Registered users can always call (205) 881 - 4630 after
  634.        5 PM CST Monday through Friday for help.
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659. Page 10
  660.  
  661.  
  662.  
  663.  
  664.                              Library Reference
  665.  
  666.  
  667.  
  668.        The  remainder  of  this manual list all the PCL functions.  Every
  669.        library function will return a value as follows:
  670.  
  671.        1.  Negative values for error conditions. See last  page  of  this
  672.            manual for a list of error values and their meanings.
  673.  
  674.        2.  Non-negative values when returning data ( eg: SioLine ).
  675.  
  676.        3.  Zero otherwise.
  677.  
  678.        When  debugging an application, be sure to test all return values.
  679.        Use SioError to print the associated text for errors.
  680.  
  681.        /*** example code segment ***/
  682.  
  683.  
  684.        RetCode := SioFunction();    (* any PCL function *)
  685.        if RetCode < 0 then begin
  686.           RetCode := SioError(RetCode);
  687.           (* ...do some stuff... *)
  688.           end;
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725. Page 11
  726.  
  727.  
  728.  
  729.  
  730.                              SioBaud
  731.  
  732.  
  733.        Function
  734.  
  735.        Sets the baud rate of the selected port.
  736.  
  737.        Syntax
  738.  
  739.        function SioBaud(Port,BaudCode : Integer) : Integer;
  740.  
  741.        Arguments
  742.  
  743.        Port     : Port selected (COM1..COM4).
  744.        BaudCode : Baud code.
  745.  
  746.        Remarks
  747.  
  748.        The  SioBaud  function  sets  the  baud rate without resetting the
  749.        port. It is used to change the baud rate after calling SioReset.
  750.  
  751.           Baud Code        Baud Rate        PCL Name
  752.              0                 300            Baud300
  753.              1                 600            Baud600
  754.              2                1200            Baud1200
  755.              3                2400            Baud2400
  756.              4                4800            Baud4800
  757.              5                9600            Baud9600
  758.              6               19200            Baud19200
  759.              7               38400            Baud38400
  760.              8               57600            Baud57600
  761.              9              115200            Baud115200
  762.  
  763.        Returns
  764.  
  765.          -2 : Port not enabled. Must call SioReset first.
  766.          -4 : Bad  port selected.  Value  must  be  0  to 3.
  767.         -11 : Bad baud rate code. See above code values.
  768.  
  769.        Example
  770.  
  771.        /* do auto baud detect */
  772.        for Code = 0 to 9 do begin
  773.           RetCode := SioBaud(Port,Code);
  774.           RetCode := SioPutc(Port,'A');
  775.           if SioGetc(Port,18) = Ord('A') then
  776.               writeln('Baud rate detected');
  777.               (*...do something here...*)
  778.               end
  779.           end;
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791. Page 12
  792.  
  793.  
  794.  
  795.  
  796.                              SioBrkKey
  797.  
  798.  
  799.        Function
  800.  
  801.        Return non-zero if the Control-BREAK key was pressed.
  802.  
  803.        Syntax
  804.  
  805.        function SioBrkKey : Integer;
  806.  
  807.        Remarks
  808.  
  809.        The SioBrkKey function returns a TRUE value ( non-zero  )  if  the
  810.        Control-BREAK  key  was  pressed,  else  it  returns  a zero.  Use
  811.        SioBrkKey as a safety exit from a polling loop.   Don't  mix  this
  812.        function up with SioBrkSig.
  813.  
  814.        Returns
  815.  
  816.        -1 : Control-BREAK was pressed.
  817.         0 : Control-BREAK was NOT pressed.
  818.  
  819.        Example
  820.  
  821.        while TRUE do begin
  822.           if SioBrkKey then begin
  823.              writeln('User typed Contrl-BREAK');
  824.              RetCode := SioDone(Port);
  825.              halt;
  826.           end;
  827.           (* do some other stuff *)
  828.        end;
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857. Page 13
  858.  
  859.  
  860.  
  861.  
  862.                              SioBrkSig
  863.  
  864.  
  865.  
  866.        Function
  867.  
  868.        Asserts, cancels, or detects BREAK signal.
  869.  
  870.        Syntax
  871.  
  872.        function SioBrkSig(Port : Integer; Cmd : Char) : Boolean;
  873.  
  874.        Arguments
  875.  
  876.        Port : Port selected (COM1,COM2,COM3,or COM4)
  877.        Cmd  : ASSERT, CANCEL, or DETECT
  878.  
  879.        Remarks
  880.  
  881.        The SioBrkSig function controls the BREAK bit in the  line  status
  882.        register. The legal commands are:
  883.  
  884.               ASSERT ('A') to assert BREAK
  885.               CANCEL ('C') to cancel BREAK
  886.               DETECT ('D') to detect BREAK
  887.  
  888.        ASSERT,  CANCEL,  and  DETECT  are defined in PCL.PAS. See CALLPGM.PAS
  889.        for an example of the use of SioBrkSig.
  890.  
  891.        Returns
  892.  
  893.         -2 : Port not enabled. Must call SioReset first.
  894.         -4 : Bad port selected. Value must be 0 to 3.
  895.         -6 : Illegal command. Expected 'A', 'C', or 'D'.
  896.         >0 : BREAK signal detected ( DETECT only )
  897.  
  898.        Example
  899.  
  900.        (* Assert BREAK for 1 second *)
  901.        RetCode := SioBrkSig(Port,ASSERT);
  902.        RetCode := SioDelay(18);
  903.        RetCode := SioBrkSig(Port,CANCEL);
  904.  
  905.        (* Detect BREAK *)
  906.        if SioBrkSig(Port,DETECT) then begin
  907.           writeln('BREAK signal detected');
  908.           (* ...do some more stuff... *)
  909.        end
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923. Page 14
  924.  
  925.  
  926.  
  927.  
  928.                              SioCrtWrite
  929.  
  930.  
  931.  
  932.        Function
  933.  
  934.        Write character to the screen.
  935.  
  936.        Syntax
  937.  
  938.        function SioCrtWrite(ch : Char) : Integer;
  939.  
  940.        Arguments
  941.  
  942.        ch = Character to write
  943.  
  944.        Remarks
  945.  
  946.        The SioCrtWrite function uses the BIOS to write a single character
  947.        to the screen at the current cursor location.
  948.  
  949.        SioCrtWrite  is  faster  than a call to  the  Pascal  library  and
  950.        for this reason is included in PCL.
  951.  
  952.        Returns
  953.  
  954.        zero
  955.  
  956.        Example
  957.  
  958.        Ch := SioGetc(COM1,18);
  959.        if Ch <> -1 then begin
  960.            (* do some stuff *)
  961.        end
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989. Page 15
  990.  
  991.  
  992.  
  993.  
  994.                              SioDTR
  995.  
  996.  
  997.  
  998.        Function
  999.  
  1000.        Set, clear, or read the Data Terminal Ready ( DTR ) bit.
  1001.  
  1002.        Syntax
  1003.  
  1004.        function SioDTR(Port,Cmd : Integer) : Integer;
  1005.  
  1006.        Arguments
  1007.  
  1008.        Port : Port selected (COM1,COM2,COM3,or COM4)
  1009.        Cmd  : DTR command ( SET, CLEAR, or READ )
  1010.  
  1011.        Remarks
  1012.  
  1013.        The  SioDTR  function controls the Data Terminal Ready ( DTR ) bit
  1014.        in the modem control register. Commands (  defined  in  PCL.PAS  )
  1015.        are:
  1016.  
  1017.                 SET ('S')  to set DTR ( ON )
  1018.                 CLEAR ('C')  to clear DTR ( OFF )
  1019.                 READ ('R')  to read DTR
  1020.  
  1021.        Returns
  1022.  
  1023.         -2 : Port not enabled. Must call RetCode := SioReset first.
  1024.         -4 : Bad port selected. Value must be 0 to 3.
  1025.         -5 : Not one of 'S', 'C', or 'R'.
  1026.          0 : DTR is OFF (READ Command).
  1027.         >0 : DTR is ON (READ Command).
  1028.  
  1029.        Example
  1030.  
  1031.        (* turn DTR on for modem connected to COM4 *)
  1032.        RetCode := SioDTR(COM4,SET);
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055. Page 16
  1056.  
  1057.  
  1058.  
  1059.  
  1060.                              RetCode := SioDelay
  1061.  
  1062.  
  1063.  
  1064.        Function
  1065.  
  1066.        Delays one or more tics.
  1067.  
  1068.        Syntax
  1069.  
  1070.        function SioDelay(Tics : Integer) : Integer;
  1071.  
  1072.        Arguments
  1073.  
  1074.        Tics : Number of timer tics ( 18.2 per second )
  1075.  
  1076.        Remarks
  1077.  
  1078.        The  SioDelay function is used to delay one or  more  timer  tics,
  1079.        where  each timer tic is approximately 55 milliseconds ( 18 to the
  1080.        second ). See SioTimer also.
  1081.  
  1082.        Returns
  1083.  
  1084.        zero
  1085.  
  1086.        Example
  1087.  
  1088.        RetCode := SioDelay(5*18);               (* delay 5 seconds *)
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121. Page 17
  1122.  
  1123.  
  1124.  
  1125.  
  1126.                              SioDone
  1127.  
  1128.  
  1129.  
  1130.        Function
  1131.  
  1132.        Terminates further serial processing.
  1133.  
  1134.        Syntax
  1135.  
  1136.        function SioDone(Port : Integer) : Integer;
  1137.  
  1138.        Arguments
  1139.  
  1140.        Port : Port selected (COM1,COM2,COM3,or COM4)
  1141.  
  1142.        Remarks
  1143.  
  1144.        The   SioDone   function  terminates  further  serial  processing.
  1145.        SioDone  MUST  be  called  before exiting your application so that
  1146.        interrupts can be restored to their original state. Failure to  do
  1147.        this  can  crash  the  operating  system.   If  you forget to call
  1148.        SioDone before exiting, be sure to re-boot your computer.
  1149.  
  1150.        Returns
  1151.  
  1152.         -2 : Port not enabled. Must call RetCode := SioReset first.
  1153.         -4 : Bad port selected. Value must be 0 to 3.
  1154.  
  1155.        Example
  1156.  
  1157.        (* terminate processing for COM3 *)
  1158.        RetCode := SioDone(COM3);
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187. Page 18
  1188.  
  1189.  
  1190.  
  1191.  
  1192.                              SioError
  1193.  
  1194.  
  1195.        Function
  1196.  
  1197.        Displays error in text.
  1198.  
  1199.        Syntax
  1200.  
  1201.        function SioError(Code : Integer) : Integer;
  1202.  
  1203.        Arguments
  1204.  
  1205.        Code : Error code returned from a PCL function
  1206.  
  1207.        Remarks
  1208.  
  1209.        The SioError function displays the error in text corresponding  to
  1210.        the   error   code.    During   development  of  a  communications
  1211.        application, it is a good idea to always test  return  codes,  and
  1212.        print out their descriptions with SioError.
  1213.  
  1214.        Returns
  1215.  
  1216.        none
  1217.  
  1218.        Example
  1219.  
  1220.        RetCode := SioReset(Port,Baud4800);
  1221.        if RetCode < 0 then RetCode := SioError(RetCode);
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253. Page 19
  1254.  
  1255.  
  1256.  
  1257.  
  1258.                              SioGetc
  1259.  
  1260.  
  1261.  
  1262.        Function
  1263.  
  1264.        Reads the next character from the serial line.
  1265.  
  1266.        Syntax
  1267.  
  1268.        function SioGetc(Port,Tics : Integer) : Integer;
  1269.  
  1270.        Arguments
  1271.  
  1272.        Port : COM1 to COM4
  1273.        Tics : Number of timer tics
  1274.  
  1275.        Remarks
  1276.  
  1277.        The  SioGetc function reads the selected serial port. The function
  1278.        will wait for the number  of  system  tics  given  by  the  'Tics'
  1279.        argument  before  returning  'timed out'. There are 18 tics to the
  1280.        second.
  1281.  
  1282.        To specify no waiting, call SioGetc with Tics = 0.
  1283.  
  1284.        Returns
  1285.  
  1286.         -2 : Port not enabled. Must call RetCode := SioReset first.
  1287.         -4 : Bad port selected. Value must be 0 to 3.
  1288.         -1 : If timed out.
  1289.         >0 : Character read.
  1290.  
  1291.        Example
  1292.  
  1293.        RetCode := SioGetc(COM1,1);
  1294.        if RetCode <> -1 then  writeln('Character is ', chr(RetCode) );
  1295.        else writeln('Timed out');
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319. Page 20
  1320.  
  1321.  
  1322.  
  1323.  
  1324.                              SioKeyPress
  1325.  
  1326.  
  1327.  
  1328.        Function
  1329.  
  1330.        Detects if keyboard has been pressed.
  1331.  
  1332.        Syntax
  1333.  
  1334.        function SioKeyPress() : Boolean;
  1335.  
  1336.        Remarks
  1337.  
  1338.        The  SioKeyPress function uses the BIOS to test the keyboard for a
  1339.        key press.
  1340.  
  1341.        Returns
  1342.  
  1343.        zero
  1344.  
  1345.        Example
  1346.  
  1347.        if SioKeyPress begin
  1348.           (* ...do something... *)
  1349.        end;
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385. Page 21
  1386.  
  1387.  
  1388.  
  1389.  
  1390.                              SioKeyRead
  1391.  
  1392.  
  1393.  
  1394.        Function
  1395.  
  1396.        Reads the keyboard.
  1397.  
  1398.        Syntax
  1399.  
  1400.        function SioKeyRead : Integer;
  1401.  
  1402.        Remarks
  1403.  
  1404.        The SioKeyRead function uses the BIOS to read the keyboard.   Will
  1405.        wait until a character is typed.
  1406.  
  1407.        SioKeyRead is faster than using the Pascal library.
  1408.  
  1409.        Returns
  1410.  
  1411.        character typed.
  1412.  
  1413.        Example
  1414.  
  1415.        if SioKeyPress then begin
  1416.            RetCode := SioKeyRead();
  1417.        end
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451. Page 22
  1452.  
  1453.  
  1454.  
  1455.  
  1456.                              SioLine
  1457.  
  1458.  
  1459.  
  1460.        Function
  1461.  
  1462.        Reads the line status register.
  1463.  
  1464.        Syntax
  1465.  
  1466.        function SioLine(Port : Integer) : Integer;
  1467.  
  1468.        Arguments
  1469.  
  1470.        Port : Port selected (COM1,COM2,COM3,or COM4)
  1471.  
  1472.        Remarks
  1473.  
  1474.        The  SioLine  function  reads  the  line  status  register.   The
  1475.        individual bit masks are as follows:
  1476.  
  1477.           $20  = Transmitter Buffer Empty.
  1478.           $10  = Break detected.
  1479.           $08  = Framming error.
  1480.           $04  = Parity error.
  1481.           $02  = Overrun error.
  1482.           $01  = Data ready.
  1483.  
  1484.        The above are documented in the file PCL.PAS.
  1485.  
  1486.           Returns
  1487.  
  1488.        -2 : Port not enabled. Must call RetCode := SioReset first.
  1489.        -4 : Bad port selected. Value must be 0 to 3.
  1490.        >0 : Line status ( rightmost byte of word ).
  1491.  
  1492.        Example
  1493.  
  1494.        RetCode := SioLine(Port);
  1495.        if(RetCode and (FramingError or ParityError or OverrunError)) <> 0
  1496.        then
  1497.           begin
  1498.              if (RetCode and FramingError) <> 0 then writeln('Framing Error');
  1499.              if (RetCode and ParityError) <> 0 then writeln('Parity Error');
  1500.              if (RetCode and OverrunError) <> 0 then writeln('Overrun Error')
  1501.           end
  1502.        else writeln('No error');
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517. Page 23
  1518.  
  1519.  
  1520.  
  1521.  
  1522.                              SioModem
  1523.  
  1524.  
  1525.  
  1526.        Function
  1527.  
  1528.        Reads the modem status register.
  1529.  
  1530.        Syntax
  1531.  
  1532.        function SioModem(Port : Integer;  Mask : Char) ; Integer;
  1533.  
  1534.        Arguments
  1535.  
  1536.        Port : Port selected (COM1,COM2,COM3,or COM4)
  1537.        Mask : Modem function mask
  1538.  
  1539.        Remarks
  1540.  
  1541.        The SioModem   function  reads  the  modem  register.   The  bit
  1542.        definitions for the function mask are as follows:
  1543.  
  1544.                 Bit    PCL.PAS Name   Function
  1545.                  7      DCD         Data Carrier Detect
  1546.                  6      RI          Ring Indicator
  1547.                  5      DSR         Data Set Ready
  1548.                  4      CTS         Clear To Send
  1549.                  3      DeltaDCD    Delta DCD   ( DCD has changed )
  1550.                  2      DeltaRI     Delta RI    ( RI has changed )
  1551.                  1      DeltaDSR    Delta DSR   ( DSR has changed )
  1552.                  0      DeltaCTS    Delta CTS   ( CTS has changed )
  1553.  
  1554.        Bits  4 through 7 represent the absolute state of their respective
  1555.        RS-232 inputs. Bits 0 through 3 repesent a change in the state  of
  1556.        their respective RS-232 inputs since last read.
  1557.  
  1558.        The above definitions are also in the PCL.PAS file for use  by  your
  1559.        application program.
  1560.  
  1561.        Returns
  1562.  
  1563.        -2 : Port not enabled. Must call RetCode := SioReset first.
  1564.        -4 : Bad port selected. Value must be 0 to 3.
  1565.        >0 : Modem status ( rightmost byte of word ).
  1566.  
  1567.        Example
  1568.  
  1569.        (* any change in DCD ? *)
  1570.        Status := SioModem(Port,DeltaDCD);
  1571.        if Status < 0 then
  1572.           begin
  1573.              RetCode := SioError(Status);
  1574.              Halt;
  1575.           end;
  1576.        else writeln('DCD status = ', SioModem(Port,DCD) );
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583. Page 24
  1584.  
  1585.  
  1586.  
  1587.  
  1588.                              SioParms
  1589.  
  1590.  
  1591.  
  1592.        Function
  1593.  
  1594.        Sets parity, stop bits, and word length.
  1595.  
  1596.        Syntax
  1597.  
  1598.        function SioParms(Port,ParityCode,StopBitsCode,WordLengthCode: Integer)
  1599.          : Integer;
  1600.  
  1601.        Arguments
  1602.  
  1603.        Port           : Port selected (COM1,COM2,COM3,or COM4)
  1604.        ParityCode     : Parity code [0,1,2]
  1605.        StopBitsCode   : Stop bits code  [0,1]
  1606.        WordLengthCode : Word length code [0,1,2,3]
  1607.  
  1608.        Remarks
  1609.  
  1610.        The SioParms function sets the parity, stop bits, and word length.
  1611.        If the default parity ( none ), stop bits ( 1 ), or word length  (
  1612.        8  )  is  not  acceptable,  then  they  can  be changed by calling
  1613.        SioParms.  SioParms can be called either before or  after  calling
  1614.        SioReset. See file PCL.PAS.
  1615.  
  1616.                         Value      Description    PCL.PAS Name
  1617.            ParityCode:   *0        no parity      NoParity
  1618.                           1        odd parity     OddParity
  1619.                           2        even parity    EvenParity
  1620.  
  1621.           StopBitsCode:  *0        1 stop bit     OneStopBit
  1622.                           1        2 stop bits    TwoStopBits
  1623.  
  1624.           WordLengthCode: 0        5 data bits    WordLength5
  1625.                           1        6 data bits    WordLength6
  1626.                           2        7 data bits    WordLength7
  1627.                          *3        8 data bits    WordLength8
  1628.  
  1629.           * = Default
  1630.  
  1631.        Returns
  1632.  
  1633.         -2 : Port not enabled. Must call RetCode := SioReset first.
  1634.         -4 : Bad port selected. Value must be 0 to 3.
  1635.         -7 : Bad parity code selected. Value must be 0 to 2.
  1636.         -8 : Bad stop bits code. Value must be 0 or 1.
  1637.         -9 : Bad word length code. Value must be 0 to 3.
  1638.  
  1639.        Example
  1640.  
  1641.        RetCode := SioParms(COM1,NoParity,OneStopBit,WordLength8);
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649. Page 25
  1650.  
  1651.  
  1652.  
  1653.  
  1654.                              SioPutc
  1655.  
  1656.  
  1657.  
  1658.        Function
  1659.  
  1660.        Transmit a character over a serial line.
  1661.  
  1662.        Syntax
  1663.  
  1664.        function SioPutc(Port : Integer; Ch : Char) : Integer;
  1665.  
  1666.        Arguments
  1667.  
  1668.        Port : Port selected (COM1,COM2,COM3,or COM4)
  1669.        Ch   : Character to send
  1670.  
  1671.        Remarks
  1672.  
  1673.        The  SioPutc  function  transmits  one character over the selected
  1674.        serial line.
  1675.  
  1676.        Returns
  1677.  
  1678.        -2 : Port not enabled. Must call RetCode := SioReset first.
  1679.        -4 : Bad port selected. Value must be 0 to 3.
  1680.  
  1681.        Example
  1682.  
  1683.        crc := 0;
  1684.        for i = 0 to 127 do begin
  1685.           crc := crcupdate( buffer[i], crc);
  1686.           RetCode := SioPutc(Port, buffer[i]);
  1687.        end;
  1688.        RetCode := SioPutc(crc);
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715. Page 26
  1716.  
  1717.  
  1718.  
  1719.  
  1720.                              SioRTS
  1721.  
  1722.  
  1723.  
  1724.        Function
  1725.  
  1726.        Sets, clears, or reads the Request  to  Send ( RTS ) line.
  1727.  
  1728.        Syntax
  1729.  
  1730.        function SioRTS(Port : Integer; Cmd : Char) : Integer;
  1731.  
  1732.        Arguments
  1733.  
  1734.        Port : COM1 to COM4
  1735.        Cmd  : RTS command ( SET, CLEAR, or READ )
  1736.  
  1737.        Remarks
  1738.  
  1739.        The SioRTS function controls the Request to Send ( RTS  )  bit  in
  1740.        the modem control register. Commands ( defined in PCL.PAS ) are:
  1741.  
  1742.                      SET ('S')  set RTS ( ON )
  1743.                      CLEAR ('C')  clear RTS ( OFF )
  1744.                      READ ('R')  read RTS
  1745.  
  1746.        Returns
  1747.  
  1748.        -2 : Port not enabled. Must call RetCode := SioReset first.
  1749.        -4 : Bad port selected. Value must be 0 to 3.
  1750.        -5 : Command is not one of 'S', 'C', or 'R'.
  1751.         0 : RTS is OFF (READ Command).
  1752.        >0 : RTS is ON  (READ Command).
  1753.  
  1754.        Example
  1755.  
  1756.        (* turn off RTS for modem *)
  1757.        RetCode := SioRTS(Port,CLEAR);
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781. Page 27
  1782.  
  1783.  
  1784.  
  1785.  
  1786.                              SioReset
  1787.  
  1788.  
  1789.        Function
  1790.  
  1791.        Initialize a serial port for processing.
  1792.  
  1793.        Syntax
  1794.  
  1795.        function SioReset(Port,BaudCode : Integer) : Integer;
  1796.  
  1797.        Arguments
  1798.  
  1799.        Port     : Port selected (COM1,COM2,COM3,or COM4)
  1800.        BaudCode : baud code
  1801.  
  1802.        Remarks
  1803.  
  1804.        The  SioReset  function  initializes  the  selected  serial  port.
  1805.        SioReset  should  be called after calling SioParm and SioRxBuf but
  1806.        before making any other calls to PCL. SioReset  uses  the  parity,
  1807.        stop  bits,  and  word  length value previously set if SioParm was
  1808.        called, otherwise the default values ( see SioParm ) are used.
  1809.  
  1810.        Recall that COM1 and COM3 share  the  same  interrupt  vector  and
  1811.        therefore  cannot  operate  simultaneously.   Similiarly, COM2 and
  1812.        COM4 cannot operate simultaneously. Any other combination  of  two
  1813.        ports can be used.
  1814.  
  1815.        See SioBaud for a list of the baud rate codes, or see "PCL.PAS".
  1816.  
  1817.        Returns
  1818.  
  1819.         -4 : Bad port selected. Value must be 0 to 3.
  1820.        -11 : Bad baud rate code selected. Value must be 0 to 9.
  1821.  
  1822.        Example
  1823.  
  1824.        RetCode := SioRxBuf(COM1,Buffer,Size128);
  1825.        RetCode := SioReset(Com1,Baud38400);
  1826.        if RetCode = 0 then writeln('RESET ok');
  1827.        else begin
  1828.           RetCode := SioError(rc);
  1829.           if (RetCode and OverrunError) <> 0 then writeln('Overrun Error');
  1830.           if (RetCode and ParityError) <> 0 then writeln('Parity Error');
  1831.           if (RetCode and FramingError) <> 0 then writeln('Framing Error');
  1832.           if (RetCode and BreakDetected) <> 0 then writeln('Break Detected');
  1833.        end;
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847. Page 28
  1848.  
  1849.  
  1850.  
  1851.  
  1852.                              SioRxBuf
  1853.  
  1854.  
  1855.  
  1856.        Function
  1857.  
  1858.        Sets up receive buffers.
  1859.  
  1860.        Syntax
  1861.  
  1862.        function SioRxBuf(Port,BufferOfs,BufferSeg,SizeCode : Integer) : Integer;
  1863.  
  1864.        Arguments
  1865.  
  1866.        Port     : Port selected (COM1,COM2,COM3,or COM4)
  1867.        Buffer   : Receive buffer
  1868.        SizeCode : Buffer size code
  1869.  
  1870.        Remarks
  1871.  
  1872.        The  SioRxBuf  function passes the address and size of the receive
  1873.        buffer to PCL. Recall that PCL requires a receive buffer for  each
  1874.        port  in  simultaneous  operation  since  the  receive function is
  1875.        interrupt driven.  SioRxBuf passes the receive buffer to  PCL  for
  1876.        both  the primary ( COM1/COM3 ) and secondary ( COM2/COM4 ) ports.
  1877.        It must be called before any incoming characters can be  received.
  1878.        SioRxBuf  should  be called before SioReset. Buffer size codes are
  1879.        listed in "PCL.PAS".
  1880.  
  1881.           Size Code       Buffer Size    PCL.PAS Name
  1882.               0              8 bytes        Size8
  1883.               1             16 bytes        Size16
  1884.               2             32 bytes        Size32
  1885.               3             64 bytes        Size64
  1886.               4            128 bytes        Size128
  1887.               5            256 bytes        Size256
  1888.               6            512 bytes        Size512
  1889.               7           1024 bytes        Size1024
  1890.               8           2048 bytes        Size2048
  1891.               9           4096 bytes        Size4096
  1892.              10           8192 bytes        Size8192
  1893.              11          16384 bytes        Size16384
  1894.  
  1895.        Returns
  1896.  
  1897.         -2 : Port not enabled. Must call RetCode := SioReset first.
  1898.         -4 : Bad port selected. Value must be 0 to 3.
  1899.        -10 : Bad buffer size code. Value must be between 0 and 11.
  1900.  
  1901.        Example
  1902.  
  1903.        RetCode := SioRxBuf( COM1, RxBuf, 128);
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913. Page 29
  1914.  
  1915.  
  1916.  
  1917.  
  1918.                              SioRxFlush
  1919.  
  1920.  
  1921.  
  1922.        Function
  1923.  
  1924.        To flush the receive buffer associated with the specified port.
  1925.  
  1926.        Syntax
  1927.  
  1928.        function SioRxFlush(Port: Integer) : Integer;
  1929.  
  1930.        Arguments
  1931.  
  1932.        Port : Port selected (COM1,COM2,COM3,or COM4)
  1933.  
  1934.        Remarks
  1935.  
  1936.        The  SioRxFlush function will delete any characters in the receive
  1937.        buffer for the  specified  port.   After  execution,  the  receive
  1938.        buffer  will  be  empty.   Call SioRxBuf after resetting a port in
  1939.        order to delete any spurious characters.
  1940.  
  1941.        Returns
  1942.  
  1943.         -2 : Port not enabled. Must call RetCode := SioReset first.
  1944.         -4 : Bad port selected. Value must be 0 to 3.
  1945.  
  1946.        Example
  1947.  
  1948.        (* setup receive buffer  and  reset port *)
  1949.        RetCode := SioRxBuf(COM1,buffer,Size1024);
  1950.        RetCode := SioReset(COM1,Baud115200);
  1951.        (* flush any spurious character *)
  1952.        RetCode := SioRxFlush(COM1);
  1953.        (* ready for serial processing ! *)
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979. Page 30
  1980.  
  1981.  
  1982.  
  1983.  
  1984.                              SioRxQue
  1985.  
  1986.  
  1987.  
  1988.        Function
  1989.  
  1990.        Returns the number of characters in the receive queue.
  1991.  
  1992.        Syntax
  1993.  
  1994.        function SioRxQue(Port : Integer) : Integer;
  1995.  
  1996.        Arguments
  1997.  
  1998.        Port : Port selected (COM1,COM2,COM3,or COM4)
  1999.  
  2000.        Remarks
  2001.  
  2002.        The SioRxQue function will return the number of characters in  the
  2003.        receive queue. It can be used to implement XON/XOFF flow control.
  2004.  
  2005.        Returns
  2006.  
  2007.         -2 : Port not enabled. Must call RetCode := SioReset first.
  2008.         -4 : Bad port selected. Value must be 0 to 3.
  2009.  
  2010.        Example
  2011.  
  2012.        RetCode := SioRxBuf(COM1,Buffer,Size128);
  2013.  
  2014.        (* implement XON / XOFF *)
  2015.        count := SioRxQue(COM1);
  2016.        if (last=XON) and (count>120) then
  2017.            begin
  2018.               RetCode := SioPutc(COM1,char(XOFF));
  2019.               last := XOFF;
  2020.            end
  2021.        if (last=XOFF) and (count<8) then
  2022.            begin
  2023.               RetCode := SioPutc(COM1,char(XON));
  2024.               last := XON;
  2025.            end
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045. Page 31
  2046.  
  2047.  
  2048.  
  2049.  
  2050.                              SioTimer
  2051.  
  2052.  
  2053.        Function
  2054.  
  2055.        Returns the number of system clock tics since midnight.
  2056.  
  2057.        Syntax
  2058.  
  2059.        function SioTimer : Integer;
  2060.  
  2061.        Remarks
  2062.  
  2063.        The SioTimer function will return the number of system clock  tics
  2064.        since  midnight,  at  18.2065  tics  per second.  This function is
  2065.        usefull for timeing various functions. Also see SioDelay.
  2066.  
  2067.        Returns
  2068.  
  2069.        timer tics
  2070.  
  2071.        Example
  2072.  
  2073.        Time := SioTimer();
  2074.  
  2075.        (* do some stuff *)
  2076.  
  2077.        writeln('Elasped time ', SioTimer - Time );
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111. Page 32
  2112.  
  2113.  
  2114.  
  2115.  
  2116.                              SioUnGetc
  2117.  
  2118.  
  2119.        Function
  2120.  
  2121.        "Un-gets" the last character read with SioGetc.
  2122.  
  2123.        Syntax
  2124.  
  2125.        function SioUnGetc(Port : Integer; Ch : Char) : Integer;
  2126.  
  2127.        Arguments
  2128.  
  2129.        Port : Port selected (COM1,COM2,COM3,or COM4)
  2130.        Ch   : Character to unget
  2131.  
  2132.        Remarks
  2133.  
  2134.        The SioUnGetc function returns ( pushes ) the character back  into
  2135.        the  serial  input  buffer.  The character pushed will be the next
  2136.        character returned by SioGetc. Only one character  can  be  pushed
  2137.        back. This function works just like the "ungetc" function in the C
  2138.        language.
  2139.  
  2140.        Returns
  2141.  
  2142.         -2 : Port not enabled. Must call RetCode := SioReset first.
  2143.         -4 : Bad port selected. Value must be 0 to 3.
  2144.  
  2145.        Example
  2146.  
  2147.        RetCode := SioUnGetc(Port,c);
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177. Page 33
  2178.  
  2179.  
  2180.  
  2181.  
  2182.                              Function Sumary
  2183.  
  2184.        +-------------+----------+----------+----------+----------+
  2185.        | Function    |   Arg1   |   Arg2   |   Arg3   |   Arg4   |
  2186.        +-------------+----------+----------+----------+----------+
  2187.        |  SioBaud    | Port     | BaudCode |          |          |
  2188.        +-------------+----------+----------+----------+----------+
  2189.        |  SioBrkKey  |          |          |          |          |
  2190.        +-------------+----------+----------+----------+----------+
  2191.        |  SioBrkSig  | Port     | Cmd      |          |          |
  2192.        +-------------+----------+----------+----------+----------+
  2193.        |  SioCrtWrite| Ch       |          |          |          |
  2194.        +-------------+----------+----------+----------+----------+
  2195.        |  SioDTR     | Port     | Cmd      |          |          |
  2196.        +-------------+----------+----------+----------+----------+
  2197.        |  SioDelay   | Tics     |          |          |          |
  2198.        +-------------+----------+----------+----------+----------+
  2199.        |  SioDone    | Port     |          |          |          |
  2200.        +-------------+----------+----------+----------+----------+
  2201.        |  SioError   | Code     |          |          |          |
  2202.        +-------------+----------+----------+----------+----------+
  2203.        |  SioGetc    | Port     | Tics     |          |          |
  2204.        +-------------+----------+----------+----------+----------+
  2205.        |  SioKeyPress|          |          |          |          |
  2206.        +-------------+----------+----------+----------+----------+
  2207.        |  SioKeyRead |          |          |          |          |
  2208.        +-------------+----------+----------+----------+----------+
  2209.        |  SioLine    | Port     |          |          |          |
  2210.        +-------------+----------+----------+----------+----------+
  2211.        |  SioModem   | Port     | Mask     |          |          |
  2212.        +-------------+----------+----------+----------+----------+
  2213.        |  SioParms   | Port     | Parity   | StopBits |WordLength|
  2214.        +-------------+----------+----------+----------+----------+
  2215.        |  SioPutc    | Port     | Ch       |          |          |
  2216.        +-------------+----------+----------+----------+----------+
  2217.        |  SioRTS     | Port     | Cmd      |          |          |
  2218.        +-------------+----------+----------+----------+----------+
  2219.        |  SioReset   | Port     | BaudCode |          |          |
  2220.        +-------------+----------+----------+----------+----------+
  2221.        |  SioRxBuf   | Port     | Buffer   | SizeCode |          |
  2222.        +-------------+----------+----------+----------+----------+
  2223.        |  SioRxFlush | Port     |          |          |          |
  2224.        +-------------+----------+----------+----------+----------+
  2225.        |  SioRxQue   | Port     |          |          |          |
  2226.        +-------------+----------+----------+----------+----------+
  2227.        |  SioTimer   |          |          |          |          |
  2228.        +-------------+----------+----------+----------+----------+
  2229.        |  SioUnGetc  | Port     | Ch       |          |          |
  2230.        +-------------+----------+----------+----------+----------+
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243. Page 34
  2244.  
  2245.  
  2246.  
  2247.  
  2248.                              Error Code Summary
  2249.  
  2250.  
  2251.  
  2252.        Code        Description
  2253.  
  2254.          0          No error.
  2255.  
  2256.         -1          Timeout waiting for input. Only returned by  SioGetc.
  2257.  
  2258.         -2          Port not enabled. Must call  SioReset first.
  2259.  
  2260.         -3          No buffer available. Must call  SioRxBuf before
  2261.                     calling SioReset.
  2262.  
  2263.         -4          Bad port specified. Must be 0 to 3. Recall that COM1
  2264.                     is port 0, COM2 is port 1, etc.
  2265.  
  2266.         -5          Expected 'S', 'C', or 'R' as second argument.
  2267.  
  2268.         -6          Expected 'A', 'C', or 'D' as second argument.
  2269.  
  2270.         -7          Bad parity code specified. Must be 0 to 7.
  2271.  
  2272.         -8          Bad stop bits code specified. Must be 0 or 1.
  2273.  
  2274.         -9          Bad wordlength code specified. Must be 0 to 3.
  2275.  
  2276.        -10          Bad buffer size code specified. Must be 0 to 11.
  2277.  
  2278.        -11          Bad baud rate code. Must be 0 to 9.
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309. Page 35
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.